package libs.yzx.zaza;

import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import libs.yzx.zaza.za.BindService;

/**
 * Created by Administrator on 2016/7/12.
 */
public class FloatViewActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_float_view);

        ListView lv = (ListView) findViewById(R.id.listview);

        MyTextView tv = new MyTextView(this);
        tv.setText("XXXX11");
        tv.setTextSize(40);
        tv.onVisibilityChangedListener = new MyTextView.OnVisibilityChangedListener() {
            public void onChange(int visibility) {
                Toast.makeText(FloatViewActivity.this, visibility == ListView.VISIBLE ? "show" : "hidden", Toast.LENGTH_SHORT).show();
            }
        };
        lv.addHeaderView(tv, null, false);

        tv.setTranslationY(300);


        lv.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, android.R.id.text1, new String[]{
                "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
        }));

        bindService(new Intent(this, BindService.class), new ServiceConnection() {
            public void onServiceConnected(ComponentName name, IBinder service) {
                BindService.MyBinder mb = (BindService.MyBinder) service;
                String s = mb.get();

            }

            public void onServiceDisconnected(ComponentName name) {

            }
        }, BIND_AUTO_CREATE);

    }

}
